/* 
 * Copyright (C) 2001-2003 Jacek Sieka, j_s@telia.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "stdafx.h"
#include "../client/DCPlusPlus.h"
#include "Resource.h"

#include "SoundsPage.h"
#include "../client/SettingsManager.h"
#include "WinUtil.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

PropPage::TextItem SoundsPage::texts[] = {
	{ IDC_SETTINGS_SOUNDS, ResourceManager::SETTINGS_SOUNDS },
	{ IDC_PRIVATE_MESSAGE_BEEP, ResourceManager::SETTINGS_PM_BEEP },
	{ IDC_PRIVATE_MESSAGE_BEEP_OPEN, ResourceManager::SETTINGS_PM_BEEP_OPEN },
	{ 0, ResourceManager::SETTINGS_AUTO_AWAY }
};

PropPage::Item SoundsPage::items[] = {
	{ IDC_PRIVATE_MESSAGE_BEEP, SettingsManager::PRIVATE_MESSAGE_BEEP, PropPage::T_BOOL },
	{ IDC_PRIVATE_MESSAGE_BEEP_OPEN, SettingsManager::PRIVATE_MESSAGE_BEEP_OPEN, PropPage::T_BOOL },
	{ IDC_BEEPFILE, SettingsManager::BEEPFILE, PropPage::T_STR },
	{ IDC_WINAMP_FORMAT, SettingsManager::WINAMP_FORMAT, PropPage::T_STR_SHOWDEFAULT },
	{ IDC_WINAMP_LOCATION, SettingsManager::WINAMP_LOCATION, PropPage::T_STR_SHOWDEFAULT },
	{ IDC_MPLAYERC_FORMAT, SettingsManager::MPLAYERC_FORMAT, PropPage::T_STR_SHOWDEFAULT },
	{ 0, 0, PropPage::T_END }
};

LRESULT SoundsPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	PropPage::translate((HWND)(*this), texts);
	PropPage::read((HWND)*this, items);

	// Do specialized reading here
	return TRUE;
}

void SoundsPage::write()
{
	PropPage::write((HWND)*this, items);
	// Do specialized writing here
	// settings->set(XX, YY);
}

LRESULT SoundsPage::onBrowse(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	TCHAR buf[MAX_PATH];

	GetDlgItemText(IDC_BEEPFILE, buf, MAX_PATH);
	tstring x = buf;

	if(WinUtil::browseFile(x, m_hWnd, false) == IDOK) {
		SetDlgItemText(IDC_BEEPFILE, x.c_str());
	}
	return 0;
}

LRESULT SoundsPage::onBrowseWinamp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	TCHAR buf[MAX_PATH];

	GetDlgItemText(IDC_WINAMP_LOCATION, buf, MAX_PATH);
	tstring x = buf;

	if(WinUtil::browseDirectory(x, m_hWnd) == IDOK) {
		SetDlgItemText(IDC_WINAMP_LOCATION, x.c_str());
	}
	return 0;
}

LRESULT SoundsPage::onHelpInfo(LPNMHDR /*pnmh*/) {
	HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_SOUNDPAGE);
	return 0;
}

/**
 * @file
 * $Id: SoundsPage.cpp 255 2005-07-16 13:06:57Z Flow84 $
 */